from app import db

from app.models.base_model import BaseModel
from app.common.enums import AuthRoleStatus


class AuthRole(BaseModel):
    __tablename__ = 'auth_role'
    __table_args__ = ({'comment': '认证角色表'})
    id = db.Column(db.Integer, primary_key=True, comment="角色ID")
    role_code = db.Column(db.String(255), unique=True, nullable=False, comment="角色标识")
    role_name = db.Column(db.String(255), nullable=False, comment="角色名称")
    role_status = db.Column(
        db.Enum(AuthRoleStatus),
        server_default=AuthRoleStatus.enabled.name,
        nullable=False,
        comment="角色状态"
    )
    description = db.Column(db.String(255), nullable=True, comment="角色描述")

    def __repr__(self) -> str:
        return "<AuthRole %s>" % self.to_json()
